import type { Feature, Point, GeoJsonProperties } from 'geojson'
import type { SymbolFeature } from '@/map'
import { highLightProperties } from '@/map/highlights'
import type { Airport } from './types'

export function airport2Feature<G extends GeoJsonProperties>(
  apt: Airport,
  properties: G
): Feature<Point, G> {
  return {
    type: 'Feature',
    geometry: {
      type: 'Point',
      coordinates: [apt.location.lng, apt.location.lat]
    },
    properties
  }
}

export function highLightAirportFeatures(apt: Airport) {
  return { symbol: [highLightAirportFeature(apt)] }
}

export function highLightAirportFeature(apt: Airport): SymbolFeature {
  const p = highLightProperties.symbol.primary(apt.id)
  return airport2Feature(apt, p)
}
